package com.marvin.springBoot.repository.impl;

import com.marvin.springBoot.repository.IDemoRepository;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.Serializable;

/**
 * @author marvin.ma
 * @create 2017-09-28 8:40
 * @desc ${DESCRIPTION}
 **/
@Repository
public class DemoRepositoryImpl implements IDemoRepository {

    @PersistenceContext
    private EntityManager entityManager;

    /**
     * 查找全部
     *
     * @param entity
     * @return
     */
    @Override
    public <T> T selectById(Class entity, Serializable id) {
        return (T)entityManager.find(entity, id);
    }
}
